package com.lemeng.controller.order;


import com.alibaba.dubbo.config.annotation.Reference;
import com.lemeng.pojo.CategoryReport;
import com.lemeng.service.CategoryReportService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;

@Component//这个注解标记这个类为组件，spring会扫描到他，会放到IOC容器中由spring管理
public class OrderTask {


    @Reference
    CategoryReportService categoryReportService;


    @Scheduled(cron = "0 0 2 * * ?")
    public void countCron(){
        String date = LocalDate.now().minusDays(1).toString();
        List<CategoryReport> cunrrentDateData = categoryReportService.findCunrrentDateData(date);
        if (cunrrentDateData!=null&&cunrrentDateData.size()>0) {
            for (CategoryReport cunrrentDateDatum : cunrrentDateData) {
                categoryReportService.add(cunrrentDateDatum);
            }
        }
    }


}
